{% extends 'base.html' %}
{% load static %}
{% load user_tags %}

  {% block title %}
  <title>个人信息</title>
  {% endblock title %}
  
  {% block css %}
  <link rel="stylesheet" href="{% static 'ztree/css/zTreeStyle/zTreeStyle.css' %}">
  {% endblock css %}
  
	{% block navheader %}
    <section class="content-header">
      <div class="container-fluid">
        <div class="row mb-1">
          <div class="col-12">
            <ol class="breadcrumb">
              <li class="breadcrumb-item active">个人信息</li>
            </ol>
          </div>
        </div>
      </div><!-- /.container-fluid -->
    </section>
	{% endblock navheader %}
	
		  {% block content %}
          <div class="card card-primary content-list">
            <div class="card-header">
              <h3 class="card-title">个人信息</h3>
				<div class="card-tools">
				  <a class="btn btn-tool" href="{% if request.next %}{{ request.next }}{% else %}{% url 'server:index' %}{% endif %}">返回</a>
				  <a class="btn btn-tool" href="{% url 'user:profile_edit' %}?next={% if request.META.QUERY_STRING %}{{ request.META.PATH_INFO }}?{{ request.META.QUERY_STRING }}{% else %}{{ request.META.PATH_INFO }}{% endif %}" title="编辑">
					<!--i class="fas fa-wrench"></i-->编辑
				  </a>
				  <!--button type="button" class="btn btn-tool" data-widget="collapse">
					<i class="fas fa-minus"></i>
				  </button>
				  <button type="button" class="btn btn-tool" data-widget="maximize">
				  <i class="fas fa-expand"></i>
                  </button>
				  <button type="button" class="btn btn-tool" data-widget="remove">
					<i class="fas fa-times"></i>
				  </button-->
				</div>
            </div>
            <!-- /.card-header -->
            <div class="card-body row">
				<div class="col-3 pt-1 pb-1 border-bottom">用户名：</div><div class="col-9 pt-1 pb-1 border-bottom">{{ user.username }}</div>
				<div class="col-3 pt-1 pb-1 border-bottom">昵称：</div><div class="col-9 pt-1 pb-1 border-bottom">{{ user.nickname }}</div>
				<div class="col-3 pt-1 pb-1 border-bottom">邮箱：</div><div class="col-9 pt-1 pb-1 border-bottom">{{ user.email }}</div>
				<div class="col-3 pt-1 pb-1 border-bottom">手机：</div><div class="col-9 pt-1 pb-1 border-bottom">{{ user.phone | default:'' }}</div>
				<div class="col-3 pt-1 pb-1 border-bottom">微信：</div><div class="col-9 pt-1 pb-1 border-bottom">{{ user.weixin | default:'' }}</div>
				<div class="col-3 pt-1 pb-1 border-bottom">QQ：</div><div class="col-9 pt-1 pb-1 border-bottom">{{ user.qq | default:'' }}</div>
				<div class="col-3 pt-1 pb-1 border-bottom">性别：</div><div class="col-9 pt-1 pb-1 border-bottom">{{ user.get_sex_display }}</div>
				<div class="col-3 pt-1 pb-1 border-bottom">角色：</div><div class="col-9 pt-1 pb-1 border-bottom">{{ user.get_role_display }}</div>
				<div class="col-3 pt-1 pb-1 border-bottom">所属组：</div><div class="col-9 pt-1 pb-1 border-bottom">{% if user.groups.all %}{% for group in user.groups.all %}<button type="button" class="btn btn-sm btn-success btn-flat">{{ group.group_name }}</button>&nbsp;&nbsp;{% endfor %}{% else %}{% endif %}</div>
				<div class="col-3 pt-1 pb-1 border-bottom">创建时间：</div><div class="col-9 pt-1 pb-1 border-bottom">{{ user.create_time | date:"Y/m/d H:i:s" }}</div>
				<div class="col-3 pt-1 pb-1 border-bottom">最后登录时间：</div><div class="col-9 pt-1 pb-1 border-bottom">{{ user.last_login_time | date:"Y/m/d H:i:s" | default:'' }}</div>
				<div class="col-3 pt-1 pb-1 border-bottom">本地SSH客户端：</div>
				<div class="col-9 pt-1 pb-1 border-bottom">
					客户端：{{ ssh_app.name | default:'' }}<br>
					程序路径：{{ ssh_app.path | default:'' }}<br>
					命令参数：{{ ssh_app.args | default:'' }}<br>
				</div>
				<div class="col-3 pt-1 pb-1 border-bottom">本地SFTP客户端：</div>
				<div class="col-9 pt-1 pb-1 border-bottom">
					客户端：{{ sftp_app.name | default:'' }}<br>
					程序路径：{{ sftp_app.path | default:'' }}<br>
					命令参数：{{ sftp_app.args | default:'' }}<br>
				</div>
				
				<div class="col-3 pt-1 pb-1 border-bottom">权限：</div>
				<div class="col-9 pt-1 pb-1 border-bottom">
					<ul id="ztree-permissions" class="ztree"></ul>
				</div>
				
				<div class="col-3 pt-1 pb-1">备注：</div><div class="col-9 pt-1 pb-1">{{ user.memo | default:'' }}</div>
            </div>
            <!-- /.card-body -->
          </div>
          <!-- /.card --> 
		  {% endblock content %}

{% block js %}
<!-- DataTables -->
<script src="{% static 'adminlte/plugins/datatables/jquery.dataTables.js' %}"></script>
<script src="{% static 'adminlte/plugins/datatables/dataTables.bootstrap4.js' %}"></script>
<script>
$("#datatables-lists").DataTable({
	language: {
		"sProcessing": "处理中...",
		"sLengthMenu": "显示 _MENU_ 项结果",
		"sZeroRecords": "没有匹配结果",
		"sInfo": "显示第 _START_ 至 _END_ 项结果，共 _TOTAL_ 项",
		"sInfoEmpty": "显示第 0 至 0 项结果，共 0 项",
		"sInfoFiltered": "(由 _MAX_ 项结果过滤)",
		"sInfoPostFix": "",
		"sSearch": "搜索:",
		"sUrl": "",
		"sEmptyTable": "表中数据为空",
		"sLoadingRecords": "载入中...",
		"sInfoThousands": ",",
		"oPaginate": {
			"sFirst": "首页",
			"sPrevious": "上页",
			"sNext": "下页",
			"sLast": "末页"
		},
		"oAria": {
			"sSortAscending": ": 以升序排列此列",
			"sSortDescending": ": 以降序排列此列"
		}
	},
	destroy: true,	// 允许重建
	bProcessing:true,  // 表格数据过多处理时显示: sProcessing
	lengthMenu: [[10, 25, 50, 100, -1], [10, 25, 50, 100, "全部"]],
	order: [],
	 //scrollY: 480,	// 滚动条
	 //scrollCollapse: true,
	 //jQueryUI: true,
	 stateSave: true,	// 保存最后一次分页信息、排序信息，当页面刷新，或者重新进入这个页面，恢复上次的状态。
	 stateDuration: 86400,	// 本地储存(0~更大)还是session储存(-1) 
});
</script>

<script src="{% static 'ztree/js/jquery.ztree.all.min.js' %}"></script>
<script>
	var setting = {
		data: {
			simpleData: {
				enable: true
			}
		}
	};

	var zNodes =[
		{
			name: "全部",
			open: true,
			children: {{ request | get_all_permission | permission_to_ztree | safe }}
		}
	];

	$(document).ready(function(){
		zTree = $.fn.zTree.init($("#ztree-permissions"), setting, zNodes);
	});
	
</script>

{% endblock js %}